package com.bt.springboot.web.controller;

import com.bt.springboot.entity.SMSCode;
import com.bt.springboot.web.service.SMSCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zkx
 * @Date 2022/12/12 13:46
 */
@RestController
@RequestMapping("/sms")
public class SMSCodeController {

	@Autowired
	private SMSCodeService smsCodeService;

	/**
	 * 获取验证码
	 * @param phoneNumber
	 * @return
	 */
	@GetMapping("/{phoneNumber}")
	public String getCode(@PathVariable String phoneNumber){
		return smsCodeService.sendCode(phoneNumber);
	}

	@PostMapping("/checkCode")
	public boolean checkCode(@RequestBody SMSCode smsCode){
		return smsCodeService.checkCode(smsCode);
	}
}
